package com.yc.cloud.portal.controller;

import com.yc.cloud.common.basic.api.ResponseResult;
import com.yc.cloud.common.basic.dto.BaseQueryParam;
import com.yc.cloud.common.orm.CommonPage;
import com.yc.cloud.entity.DeviceGpsLogs;
import com.yc.cloud.entity.DeviceStatusLogs;
import com.yc.cloud.portal.service.DeviceCaptureLogsService;
import com.yc.cloud.portal.service.DeviceGpsLogsService;
import com.yc.cloud.portal.service.DeviceOcrLogsService;
import com.yc.cloud.portal.service.DeviceStatusLogsService;
import com.yc.cloud.portal.vo.DeviceCaptureLogsVo;
import com.yc.cloud.portal.vo.DeviceOcrLogsVo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.val;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * 设备抓拍记录
 *
 * @author Yancy
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/device")
@Api(value = "设备日志管理", tags = "设备抓拍记录")
public class DeviceLogsController {

    private final DeviceCaptureLogsService deviceCaptureLogsService;

    private final DeviceStatusLogsService deviceStatusLogsService;

    private final DeviceOcrLogsService deviceOcrLogsService;

    private final DeviceGpsLogsService deviceGpsLogsService;

    public DeviceLogsController(DeviceCaptureLogsService deviceCaptureLogsService, DeviceStatusLogsService deviceStatusLogsService, DeviceOcrLogsService deviceOcrLogsService, DeviceGpsLogsService deviceGpsLogsService) {
        this.deviceCaptureLogsService = deviceCaptureLogsService;
        this.deviceStatusLogsService = deviceStatusLogsService;
        this.deviceOcrLogsService = deviceOcrLogsService;
        this.deviceGpsLogsService = deviceGpsLogsService;
    }

    @GetMapping("basicinfo/logs")
    @ApiOperation(value = "设备状态记录列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<DeviceStatusLogs>> listBasicInfoLogs(@Validated BaseQueryParam param) {
        val result = deviceStatusLogsService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }

    @GetMapping("capture/logs")
    @ApiOperation(value = "设备抓拍记录列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<DeviceCaptureLogsVo>> listCaptureLogs(@Validated BaseQueryParam param) {
        val result = deviceCaptureLogsService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }


    @GetMapping("ocr/logs")
    @ApiOperation(value = "OCR识别记录列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<DeviceOcrLogsVo>> listOcrLogs(@Validated BaseQueryParam param) {
        val result = deviceOcrLogsService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }

    @GetMapping("gps/logs")
    @ApiOperation(value = "GPS上报记录列表", notes = "支持分页查询,字段模糊匹配,排序等")
    public ResponseResult<CommonPage<DeviceGpsLogs>> listGpsLogs(@Validated BaseQueryParam param) {
        val result = deviceGpsLogsService.list(param);
        return ResponseResult.success(CommonPage.restPage(result));
    }

}
